﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using DaInterFace;
using DaInterFace.PDA;
using DaInterFace.PDA.P02;

namespace P02
{
    /// <summary>
    /// 执行采样删除操作
    /// </summary>
    public class A07 : IPDAChild
    {
        public void Code(IPDA handler, CodeResult CR, PDACodeUser user, String parameter)
        {
            P02A07P P = (P02A07P)handler.SerialApi.Deserialize(typeof(P02A07P), parameter, CR.SerialType);

            try
            {
                Recordset rs = handler.Data.ExeProcedure(P.BaseNo, String.Format("EXEC  KEW_SAMP_DELETE '{0}'", Common.FilterSql(P.BillID)));
                if (rs.Enable)
                {
                    if (rs.Data.Tables[0].Rows[0][0].ToString() == "TRUE")
                    {
                        CR.Result = EnumResult.Normal;
                        CR.Message = String.Format("操作员{0}对账套{1}中的取样单进行了删除操作{2}", user.UserName, P.BaseNo, P.BillID);
                    }
                    else
                    {
                        CR.Result = EnumResult.Error;
                        CR.Message = rs.Data.Tables[0].Rows[0][1].ToString();
                    }
                }
                else
                {
                    CR.Result = EnumResult.Error;
                    CR.Message = "数据库错误";
                }
            }
            catch (Exception ex)
            {
                CR.Result = EnumResult.Error;
                CR.Message = String.Format("发生错误:{0}", ex.Message);
            }
        }
    }


}
